<template>
    <view class="services">
      <view class="service-item" v-for="(service, index) in services" :key="index">
        <button class="service-button" @click="goToService(service.name)">
          <image :src="service.icon" class="service-icon" />
        </button>
        <view class="service-name">{{ service.name }}</view>
      </view>
    </view>
</template>

<script>
export default {
  data() {
    return {
	services: [
        { name: '宠物用品', icon: '/static/icons/petaccessories.png' },
        { name: '宠物', icon: '/static/icons/pet.png' },
        { name: '其他', icon: '/static/icons/recommend.png' },
      ]
    };
  },
  methods: {
    goToService(serviceName) {
      uni.navigateTo({
        url: `/pages/pet/pet?service=${serviceName}`
      });
    },
}
};
</script>

</script>

<style scoped>
.service-button {
  background-color: #ffd700;
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: 20px;
  font-weight: bold;
  margin-top: 10px;
}
.services {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  background-color: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.service-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20%;
  margin: 10px 1%;
  background-color: #f9f9f9;
  border-radius: 10px;
  padding: 10px;
  transition: background-color 0.3s;
}

.service-item:hover {
  background-color: #f0f0f0;
}

.service-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
}

.service-name {
  font-size: 14px;
  color: #666;
}

.service-button {
  background-color: transparent;
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
</style>